<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li v-for="item in arr" :key="item.id" :class="{completed: item.isDone}" >
      <div class="view">
        <input v-model="item.isDone" class="toggle" type="checkbox" />
        <label>{{item.name}}</label>
        <button class="destroy" @click="onDel(item.id)"></button>
      </div>
    </li>
  </ul>
  
</template>

<script>
export default {
  // 子接收父传递过来的数据
  props:['arr'],
  methods:{
    onDel(id){
      // this.arr.splice(id,1)
      this.$emit('delItem',id)
    }
  }
}
</script>